package com.yxr.controller;


import com.yxr.domain.ResponseResult;
import com.yxr.domain.entity.SgArticle;
import com.yxr.service.SgArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.websocket.server.PathParam;
import java.util.List;

@RestController
@RequestMapping("/article")
public class SgArticlecontroller {

    @Autowired
    private SgArticleService articleService;



    @GetMapping("/hotArticleList")
    public ResponseResult<List<SgArticle>> hotArticleList(){
        ResponseResult result = articleService.hotArticleList();

        return result;

    }

    @GetMapping("/articleList")
    public ResponseResult articleList(Integer pageNum,Integer pageSize,Long categoryId){
       return articleService.articleList(pageNum,pageSize,categoryId);

    }

    @GetMapping("/{id}")
    public ResponseResult getArticalDetail(@PathVariable("id") Long id){
       return articleService.getArticalDetail(id);
    }


    @PutMapping("/updateViewCount/{id}")
    public ResponseResult updateViewCount(@PathVariable("id") Long id){
        return articleService.updateViewCount(id);
    }

}
